# coding: utf-8

class Solution:
    def makeGood(self, s: str) -> str:
        # 使用堆栈
        stack = []
        for ch in s:
            if stack and abs(ord(stack[-1])-ord(ch)) == 32:
                stack.pop()
            else:
                stack.append(ch)

        return ''.join(stack)


if __name__ == '__main__':
    solu = Solution()
    print(solu.makeGood('abBAcC'))
    # print(solu.isMatch('ab', 'aab'))
